home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4573 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: doc.ic.ac.uk!not-for-mail
  2. From: mdf@doc.ic.ac.uk (Martin Frost)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: 3 bugs in SAS/C v. 6.56
  5. Date: 1 Mar 1996 13:25:24 -0000
  6. Organization: Dept. of Computing, Imperial College, University of London, UK.
  7. Distribution: world
  8. Message-ID: <4h6ts4$ldq@oak43.doc.ic.ac.uk>
  9. References: <4gjvvc$a3t@gjallar.daimi.aau.dk>
  10. Reply-To: mdf@doc.ic.ac.uk (Martin Frost)
  11. NNTP-Posting-Host: oak43.doc.ic.ac.uk
  12. Keywords: SAS/C,bug
  13. X-Newsreader: mxrn 6.18-23
  14.  
  15.  
  16. In article <4gjvvc$a3t@gjallar.daimi.aau.dk>, liborius@daimi.aau.dk (Per Liboriussen) writes:
  17. >union un {
  18. >    const char *cp;
  19. >    char *p;
  20. >};
  21.  
  22. >const char *foo(union un *unp, int n)
  23.  ^^^^^
  24. >{
  25. >    return (n ? unp->p : unp->cp);
  26. >}
  27.  
  28. By returning unp->p from foo(), you are returning a char * where const char *
  29. is specified. The compiler should probably flag this as the error.
  30. As assigning to unp->p causes the error, I think that the compiler has
  31. redefined unp->p as a const char * to fit the return type of foo(). Your
  32. program is not entirely correct, so you can't really complain.
  33.  
  34. Try removing the const and see if the problem goes away.
  35.  
  36. Martin
  37.